#ifndef RS232_MOTOR_H
#define RS232_MOTOR_H

#include <fcntl.h>

typedef struct 
{
    int SpeedFront;
    int SpeedRear;
    int IR;
    int IR2;
    int robot_voltage;
    int odometry;
    int robot_current;
    int robot_version;
} RS232Data;

class RS232Motor 
{

public:
    RS232Motor();
    
    int SetRS232Motor33f_low_res(int hCOM,char speed1,char speed2);
    int SetRS232Motor33f(int hCOM,short speed1,short speed2,unsigned char SpeedFlag);
    int SetRS232MotorPID33f(int hCOM,char speed1,char speed2,char pp,char ii,char dd,short maxspeed);
    int StopMotorRS23233f(int hCOM);
    int GetRS232Motor33f(int hCOM,RS232Data *dataL,RS232Data *dataR);
    
    int openRS232(const char *device, int baudrate);
    int readRS232(int hCOM, unsigned char *buffer, unsigned int nNumberOfBytesToRead, unsigned int *lpNumberOfBytesRead);
    int closeRS232(int hCOM );
    int writeRS232(int hCOM, unsigned char *buffer, unsigned int nNumberOfBytesToWrite, unsigned int *lpNumberOfBytesWritten);
};

short CRC16(unsigned char *adresse_tab , unsigned char taille_max);

#endif //RS232_MOTOR_H
